package com.braveman.im.ui.activity.message;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.CompoundButton;

import com.braveman.im.R;
import com.braveman.im.ui.weiget.ButtonItem;
import com.braveman.im.ui.weiget.CustomPopwindow;
import com.braveman.im.ui.weiget.DialogUtils;
import com.braveman.im.ui.weiget.UISwitchButton;
import com.braveman.im.utils.UtilsStyle;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.UIUtils;
import com.vondear.rxtools.RxBarTool;


public class CompanyInfoActivity extends BaseActivity {
    private ButtonItem mBtiActivityCompanyName;
    private ButtonItem mBtiActivityCompanyNotice;
    private ButtonItem mBtiActivityCompanyMembers;
    private ButtonItem mBtiActivityCompanyManager;
    private ButtonItem mBtiActivityCompanyAdd;
    private ButtonItem mBtiActivityCompanyHintSetting;
    private UISwitchButton mSwBtnActivityCompanyNotifySetting;
    private String groupId;


    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("单位信息").setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ActivityUtils.finishActivity(CompanyInfoActivity.this);
            }
        });
    }

    @Override
    protected int initContentView() {
        UtilsStyle.setStatusBarMode(this, true);
        RxBarTool.FlymeSetStatusBarLightMode(getWindow(), true);
        RxBarTool.MIUISetStatusBarLightMode(getWindow(), true);
        return R.layout.activity_compand_info;
    }

    @Override
    protected void initIntentData(Intent callIntent) {
        groupId = callIntent.getStringExtra("groupId");
    }

    @Override
    protected void initChildView() {
        mBtiActivityCompanyName = (ButtonItem) findViewById(R.id.bti_activity_company_name);
        mBtiActivityCompanyNotice = (ButtonItem) findViewById(R.id.bti_activity_company_notice);
        mBtiActivityCompanyMembers = (ButtonItem) findViewById(R.id.bti_activity_company_members);
        mBtiActivityCompanyManager = (ButtonItem) findViewById(R.id.bti_activity_company_manager);
        mBtiActivityCompanyAdd = (ButtonItem) findViewById(R.id.bti_activity_company_add);
        mBtiActivityCompanyHintSetting = (ButtonItem) findViewById(R.id.bti_activity_company_hint_setting);
        mSwBtnActivityCompanyNotifySetting = (UISwitchButton) findViewById(R.id.sw_btn_activity_company_notify_setting);

    }

    @Override
    protected void initChildData() {
        mBtiActivityCompanyName.tv_des.setText("测试公司");
    }

    @Override
    protected void setChildViewListener() {
        mBtiActivityCompanyNotice.setOnClickListener(this);
        mBtiActivityCompanyMembers.setOnClickListener(this);
        mBtiActivityCompanyManager.setOnClickListener(this);
        mBtiActivityCompanyAdd.setOnClickListener(this);
        mBtiActivityCompanyHintSetting.setOnClickListener(this);
        mSwBtnActivityCompanyNotifySetting.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                UIUtils.showToast(b ? "消息提醒开启" : "消息提醒关闭");
            }
        });
    }


    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.bti_activity_company_notice:
                Bundle bundle = new Bundle();
                bundle.putString("groupId", groupId);
                bundle.putString("groupType", "company");
                ActivityUtils.startActivity(CompanyInfoActivity.this, SendCompanyNotifyActivity.class, bundle);
                break;
            case R.id.bti_activity_company_members:
                break;
            case R.id.bti_activity_company_manager:
                ActivityUtils.startActivity(CompanyInfoActivity.this, CompanyManagerActivity.class);
                break;
            case R.id.bti_activity_company_add:
                break;
            case R.id.bti_activity_company_hint_setting:
                DialogUtils.createPopwindow(this, "选择群的消息提醒方式", "取消", new CustomPopwindow.OnBtnClickListener("接受消息但不提醒") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {
                        mBtiActivityCompanyHintSetting.tv_title_del.setText("接受消息但不提醒");
                    }
                }, new CustomPopwindow.OnBtnClickListener("屏蔽群消息") {
                    @Override
                    public void onClick(CustomPopwindow popwindow, View view) {
                        mBtiActivityCompanyHintSetting.tv_title_del.setText("屏蔽群消息");
                    }
                }).showAtLocation(mBtiActivityCompanyHintSetting, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 130);
                break;

        }
    }

}
